cmake_minimum_required ( VERSION 3.10 )
set ( APP_NAME mini_redis )
set ( CMAKE_C_STANDARD 11 )
set ( EXAMPLE_BUILD ON )
project ( ${APP_NAME} C )

# 包含头路径
include_directories ( 3rdparty )
include_directories ( include )
include_directories ( src )

if ( WIN32 )
else ()
    # linux多线程
    find_package ( Threads )
endif ()
# 添加构建*.c、*.h文件
file ( GLOB_RECURSE BASE_SRC ${CMAKE_SOURCE_DIR}/src/*.cpp ${CMAKE_SOURCE_DIR}/src/*.c )
file ( GLOB_RECURSE BASE_INCLUDE ${CMAKE_SOURCE_DIR}/include/*.h ${CMAKE_SOURCE_DIR}/include/*.h )
if ( ${EXAMPLE_BUILD} STREQUAL "ON" ) # 是否加载example模块
    add_definitions ( -D__DEBUG_EXEC )# DEBUG宏定义
    file ( GLOB_RECURSE EXAMPLE_SRC ${CMAKE_SOURCE_DIR}/example/*.cpp ${CMAKE_SOURCE_DIR}/example/*.c )
    file ( GLOB_RECURSE EXAMPLE_INCLUDE ${CMAKE_SOURCE_DIR}/example/*.h ${CMAKE_SOURCE_DIR}/example/*.h )
    add_executable ( ${APP_NAME} ${BASE_SRC} ${BASE_INCLUDE} ${EXAMPLE_SRC} ${EXAMPLE_INCLUDE} )
else ()
    add_executable ( ${APP_NAME} ${BASE_SRC} ${BASE_INCLUDE} )
endif ()
if ( WIN32 )
    target_link_libraries ( ${APP_NAME} )
else ()
    target_link_libraries ( ${APP_NAME} pthread ) # pthread包含多线程库
endif ()